package com.kitty.web.controller;

import com.kitty.web.controller.BaseController;
import com.kitty.web.common.AjaxResult;
import com.kitty.web.core.page.TableDataInfo;
import com.kitty.web.domain.PChoujiangset;
import com.kitty.web.system.choujiangset.service.IPChoujiangsetService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;

import java.util.List;


/**
 * 抽奖Controller
 * 
 * @author soul
 * @date 2022-04-23
 */
@Controller
@RequestMapping("/system/choujiangset")
public class PChoujiangsetController extends BaseController
{
    private String prefix = "system/choujiangset";

    @Autowired
    private IPChoujiangsetService pChoujiangsetService;


    @GetMapping()
    public String choujiangset()
    {
        return prefix + "/choujiangset";
    }

    /**
     * 查询抽奖列表
     */

    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(PChoujiangset pChoujiangset)
    {
        startPage();
        List<PChoujiangset> list = pChoujiangsetService.selectPChoujiangsetList(pChoujiangset);
        return getDataTable(list);
    }



    /**
     * 新增抽奖
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存抽奖
     */

    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(PChoujiangset pChoujiangset)
    {
        return toAjax(pChoujiangsetService.insertPChoujiangset(pChoujiangset));
    }

    /**
     * 修改抽奖
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        PChoujiangset pChoujiangset = pChoujiangsetService.selectPChoujiangsetById(id);
        mmap.put("pChoujiangset", pChoujiangset);
        return prefix + "/edit";
    }

    /**
     * 修改保存抽奖
     */

    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(PChoujiangset pChoujiangset)
    {
        return toAjax(pChoujiangsetService.updatePChoujiangset(pChoujiangset));
    }

    /**
     * 删除抽奖
     */

    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(pChoujiangsetService.deletePChoujiangsetByIds(ids));
    }
}
